<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>出库</title>
</head>
<body>
<script type="text/javascript">
$(function(){
	$("#eos_Delivery_open").textbox({onClickButton: function(){
		$("#eos_Delivery_select").window("open");
	}});
	
});

function saveDelivery(){
	$("#from_Delivery_save").form({
		onSubmit: function(param){
			var rows = $("#order_delivery_dg").datagrid("getRows");
			for(var i = 0; i < rows.length; i ++){
				param['deliveryDetail[' + i +'].vdetailName'] = rows[i].rdetail_name;
				param['deliveryDetail[' + i +'].vdetailComp'] = rows[i].rdetail_comp;
				param['deliveryDetail[' + i +'].vdetailNum'] = rows[i].rdetail_num;
				param['deliveryDetail[' + i +'].vdetailRemarks'] = rows[i].rdetail_reason;
				param['deliveryDetail[' + i +'].vdetailEquipsaveid'] = rows[i].rdetail_equipsaveid;
			}
			var isValid = $(this).form('validate');
			if (!isValid){
				$.messager.progress('close');	// 如果表单是无效的则隐藏进度条
			}
			return isValid;	// 返回false终止表单提交	
		},
		success: function(v){
			var json = eval("(" + v + ")");
			$.messager.alert("操作提示", 
					json.success ? "操作成功" 
					: ("操作失败，原因为：" + json.reason));
			$("#from_Delivery_save").form("clear");
			var rows = $("#order_delivery_dg").datagrid("getRows");
			for(var i=rows.length-1;i>=0;i--){
				$("#order_delivery_dg").datagrid('deleteRow', i);
			}
			initDeliveryId();
		}
	});
	$("#from_Delivery_save").submit();
}
</script>
<div class="easyui-panel" data-options="border:false,fit:true,onOpen:initDeliveryId">
	<form id="from_Delivery_save" action="get_DeliverySave" method="post"> 
		<table width="100%" border="0" style="padding:6px;">
		<tr>
			<td style="width: 30%;"><input name="delivery.deliveryId" class="easyui-textbox" label="领用编号*" id="deliveryId" style="width:200px"></td>
			<td style="width: 35%;">
				<select name="delivery.deliveryTept" style="width:50%;" class="easyui-combotree" label="领用科室" 
						data-options="url:'to_QueryAllOffice',panelHeight: 'auto',required:true,validType:'isBlank',valueField:'text'">		
				</select>
			</td>
			<td style="width: 30%;"><input name="delivery.deliveryDate" style="width:60%;" class="easyui-datebox" label="领用日期" value="1"
			/></td>
		</tr>
		
		<tr>
			<td style="width: 30%;"><select name="delivery.deliveryKeeper" style="width:54%;" class="easyui-combobox" label="仓管员" data-options="panelHeight: 'auto',required:true,validType:'isBlank'">
								<option value=""></option>
								<option value="张鑫">张鑫</option>
								<option value="李四">李四</option>
				</select></td>	
			<td style="width: 30%;"><input name="delivery.deliveryAgent" style="width:50%;" class="easyui-textbox" label="经办人" data-options="required:true,validType:'isBlank'"/></td>			
		</tr>
		
		</table>
	
	<div class="easyui-panel" title="领用设备器材" border="0">
		<table>
		<tr>
			<td><input id="eos_Delivery_open" class="easyui-textbox" label="设备器材" data-options="buttonText:'选择',width:300">
			</td>
			<td><input id="delivery_num" class="easyui-numberbox" type="hidden" eadonly="readonly" >
			</td>
			<td style="width: 30%;"><input  id="delivery_realNum" class="easyui-numberbox" label="领用数量" >
			</td>
			<td style="width: 30%;"><input id="delivery_company" class="easyui-textbox" label="单位" readonly="readonly">	
			</td>
		</tr>
		<tr>
			<td><input id="delivery_reason" class="easyui-textbox" label="出库备注" 
			data-options="multiline:true,height:50,width:400"></td>	
			<td><input id="delivery_equipsaveid"  type="hidden" class="easyui-textbox" readonly="readonly">	
			</td>
		</tr>
		</table>
		
		<div>
			<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true" onclick="appendDelivery()">添加</a>
			<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-remove',plain:true" onclick="removeiDelivery()">删除</a>
		</div>		
		<div class="easyui-panel" border="0" style="margin:5px;">
			  <table class="easyui-datagrid" style="width: 100%;" id="order_delivery_dg"
			data-options="url:'',fitColumns:true,rownumbers: true">
			<thead>
				<tr>
					<th data-options="field:'rdetail_equipsaveid', hidden:true">id</th>
					<th style="width:20%" data-options="field:'rdetail_name'">领用设备器材名</th>
					<th style="width:20%" data-options="field:'rdetail_num'">数量</th>
					<th style="width:20%" data-options="field:'rdetail_comp'">单位</th>					
					<th style="width:40%" data-options="field:'rdetail_reason'">备注</th>					
				</tr>
			</thead>					
			</table>			
		</div>
	</div>
	<div style="margin: 5px 3px;">
		<a onclick="saveDelivery()" class="easyui-linkbutton" iconCls="icon-save">确认</a>
	</div>
</form>

	<div id="eos_Delivery_select" class="easyui-window" title="选择设备器材"
			data-options="collapsible:false,minimizable:false,maximizable:false,modal:true,iconCls:'icon-add',closed:true"
			style="width: 800px; height: 400px; padding: 5px;">
		<div style="margin-left: 5px;">
		<div style="margin: 10px">
		
			设备器材名称<input id="equipDelivery_Name" style="width: 15%;" class="easyui-textbox" > 			
			<a href="#" class="easyui-linkbutton"   style="width: 8%;"  iconCls="icon-search"  data-options="onClick:equipDeliveryWhere" >查询</a>					
		</div>	
			<table class="easyui-datagrid" style="width: 100%;height:300px;" id="ableESO_list_dg"		
				data-options="url:'get_ableESOlist',fitColumns:true,pagination:true,rownumbers: true,singleSelect:true,onDblClickRow:getAbleESOlist">
				<thead>
					<tr>
					<th style="width: 15%" data-options="field:'equipsaveBatchid'">批次号</th>
					<th style="width: 17%" data-options="field:'equipsaveName'">名称</th>
					<th style="width: 20%" data-options="field:'equipsaveBusiness'">供应商</th>
					<th style="width: 10%" data-options="field:'equipsaveNum'">数量</th>
					<th style="width: 10%" data-options="field:'equipsaveUntil'">单位</th>
					<th style="width: 10%" data-options="field:'equipsaveBdate'">生产日期</th>
					<th style="width: 10%" data-options="field:'equipsaveEdate'">有效日期</th>
					<th style="width:10%" data-options="field:'equipsaveState'">状态</th>					
				</tr>
				</thead>
			</table>
		</div> 					
	</div>	
</div>
</body>
</html>